<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="lib/react.development.js"></script>
    <script src="lib/react-dom.development.js"></script>
    <script src="lib/babel.min.js"></script>

</head>
<body>
    <div id="root"></div>

    <script type="text/babel">
        class App extends React.Component {
            constructor(){
                super();
                this.h3Ref =React.createRef();
                this.state = {
                    a:1
                }
                console.log("1-constructor");
            }
            UNSAFE_componentWillMount(){
                // 组件即将挂载
                this.state.a = 100;
                console.log("2-componentDidMount",this.h3Ref);
            }
            render() {
                console.log("3->render");
                return (
                    <div>
                        <h3 ref={this.h3Ref}>app:{this.state.a}</h3>    
                    </div>
                )
            }
            ComponentDidMount(){
                // 当组件挂载完毕之后执行
                console.log("4-componentDidMount",this.h3Ref);
            }
        }
        const root = ReactDOM.createRoot(document.querySelector("#root"));
        root.render(
            <App></App>
        )
    </script>
</body>
</html>